package com.recsmile.sgs.client.commonds.sync;

import com.recsmile.sgs.client.card.Card;
import com.recsmile.sgs.client.commonds.GeneralGameUIClientCommand;
import com.recsmile.sgs.client.entity.Hero;
import com.recsmile.sgs.client.entity.InvalidPlayerCommandException;
import com.recsmile.sgs.client.entity.PlayerCompleteClient;
import com.recsmile.sgs.client.ui.components.GamePanel;

public class SyncPlayerCardGameUIClientCommand extends GeneralGameUIClientCommand {
	private static final long serialVersionUID = 5370641268667157302L;

	private final Card card;
	private final boolean add;
	
	public SyncPlayerCardGameUIClientCommand(Card card, boolean add) {
		this.card = card;
		this.add = add;
	}

	@Override
	public void execute(GamePanel<? extends Hero> panel) {
		PlayerCompleteClient player = panel.getContent().getSelf();
		if (add) {
			player.addCard(card);
		} else {
			try {
				player.removeCardFromHand(card);
			} catch (InvalidPlayerCommandException e) {
				e.printStackTrace();
			}
		}
	}

}
